package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"websocket/commom"
	"websocket/controller"
)

func CollectRoute(r *gin.Engine) *gin.Engine {

	r.Use(commom.Cors()) // 如需跨域可以打开
	//定义 ws的连接方法
	r.GET("/ws", commom.AuthMiddleware1(), controller.WsHandler)
	r.StaticFS("/html", http.Dir("html"))
	///注册普通图片显示
	//http.Handle("/img/",http.StripPrefix("/img/",http.FileServer(http.Dir("./html/image"))))
	//注册 html 文件的访问
	//http.Handle("/", http.FileServer(http.Dir("./html")))

	//	r.LoadHTMLGlob("html/")
	//注册头像遍历接口
	//http.HandleFunc("/api/avaterlist",server.GetAvaterList)

	r.GET("/api/auth/screenFriendList", commom.AuthMiddleware(), controller.ScreenFriendList)
	r.GET("/api/auth/messageItemList", commom.AuthMiddleware(), controller.MessageItemList)
	r.GET("/api/auth/messageList", commom.AuthMiddleware(), controller.MessageList)
	r.POST("/api/auth/register", controller.Register)
	r.POST("/api/auth/login", controller.Login)
	r.GET("/api/auth/info", commom.AuthMiddleware(), controller.Info)
	r.POST("/api/auth/addFriendList", commom.AuthMiddleware(), controller.AddFriendList)

	return r
}
